package cate.game.role.res.guild.msg.envelope;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdGuild;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "发福利红包的请求")
@OperationSetter(value = GDOperation.GUILD_GET_ENVELOPE)
public class GiveBenefitEnvelopeReq implements MsgInput {
    @NoteField(value = "红包类型ID")
    public int id;

    @Override
    public MsgConfig conf() {
        return MsgIdGuild.GIVE_BENEFIT_RED_ENVELOPE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        Role role = cc.getRole();
        EcResult r = role.getRes().guild.checkGuild();
        if (r.ok()) {
            role.getRes().guild.envelope.sendRedEnveLope(id);
        } else {
            game.notice.message(cc.getRole(), 310450,"尚未加入公会");
        }
    }
}
